package cn.letlet.util;
import cn.letlet.data.Data;
import cn.letlet.ui.ChessboadView;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.Handler;
import android.os.Message;
import cn.letlet.utils.Debug;

public class AiThread extends Thread {
	private Context context;
	private Handler han;
	AiInterface aiFace = AiInterface.getInstance();
	ChessboadView mboardView = ChessboadView.getInstance(context, han);
	
	public AiThread(Context context, Handler han) {
		super();
		this.context = context;
		this.han = han;
	}

	public void run(){
		while(true){//TODO 这里要修改以节省资源
			if(AiInterface.bestMove!=Data.NULL_BESTMOVE){
				if(!AiInterface.bestMove.equals("draw")&&!AiInterface.bestMove.equals("resign")&&!AiInterface.bestMove.equals("nobestmove")){
					Debug.d(AiInterface.bestMove);
					int[] cord_xy = LetUtil.ICCStoSq(AiInterface.bestMove);
					mboardView.aiResponseMove(cord_xy[0],cord_xy[1],AiInterface.bestMove);
					AiInterface.bestMove = "no";
				}else{
					mboardView.aiResponseLose();
					AiInterface.bestMove = "no";
				}
			}
		}
	}

}
